<template>
  <div>
    <img
      src="https://akk.028wkf.cn/kdb-weapp-img/new-kdb-xcx/img/-s-pic-yd1@2x.png"
      mode="widthFix"
      class="bg"
    />
    <div class="formInfo">
      <input
        v-model="phone"
        class="loginInput"
        type="number"
        placeholder="请输入手机号码"
        placeholder-class="placeholder-part"
        maxlength="11"
      />
      <button class="btn-color-blue loginBtn" @click="handleClick">下一步</button>
    </div>
  </div>
</template>

<script>
// import { encryptMD5 } from '@/utils'
import { FIND_CUSTOMER_BY_PHONE } from '@/api'

export default {
  components: {},
  props: {},
  data () {
    return {
      phone: ''
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  onShow () {},
  methods: {
    handleClick () {
      const vm = this
      if (vm.phone) {
        vm._findCustomerByPhone()
      } else {
        vm.$toast('请输入手机号码')
      }
    },
    _findCustomerByPhone () {
      const vm = this
      FIND_CUSTOMER_BY_PHONE(vm.$store.state.account.providerId, vm.phone)
        .then(r => {
          if (r.data.code === '0') {
            if (r.data.data) {
              vm.$router.push(
                `/pages/open-shop/store-pass/main?phone=${vm.phone}`
              )
            } else {
              vm.$router.push(
                `/pages/open-shop/store-register/step2/main?phone=${vm.phone}`
              )
            }
          } else {
            vm.$toast(r.data.message)
          }
        })
        .catch(e => {
          console.error(e)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'static/styles/color.scss';
.bg {
  width: 100%;
  height: 100vw;
}
.formInfo {
  width: 90%;
  margin: auto;
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, 0);
  .loginInput {
    font-size: 14px;
    color: #999999;
    border-bottom: 1px solid #e8e8e8;
    padding-right: 3px;
    height: 40px;
  }
  .loginBtn {
    border-radius: 25px;
    line-height: 40px;
    margin-top: 30px;
  }
}
</style>
